import Vue from 'vue'
import VueRouter from 'vue-router'
import LoginView from '@/views/LoginView.vue'
import ManagerView from '@/views/ManagerView.vue'
import HomeView from '../views/manager/HomeView.vue'
import AdminView from '@/views/manager/AdminView.vue'
import UserView from '@/views/manager/UserView.vue'
import BannerView from '@/views/manager/BannerView.vue'
import ArticleView from '@/views/manager/ArticleView.vue'
import GoodsView from '@/views/manager/GoodsView.vue'
import TrashcanView from '@/views/manager/TrashcanView.vue'
import RegisterView from '@/views/RegisterView.vue'
import OrderView from '@/views/manager/OrderView.vue'
import RecyclingOrderView from '@/views/manager/RecyclingOrderView.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'manager',
    redirect: '/home', // 重定向到主页
    component: ManagerView,
    children: [
      { path: 'home', name: 'home', component: HomeView },
      { path: 'admin', name: 'admin', component: AdminView },
      { path: 'user', name: 'user', component: UserView },
      { path: 'banner', name: 'banner', component: BannerView },
      { path: 'article', name: 'article', component: ArticleView },
      { path: 'goods', name: 'goods', component: GoodsView },
      { path: 'trashcan', name: 'trashcan', component: TrashcanView },
      { path: 'order', name: 'order', component: OrderView },
      { path: 'recyclingOrder', name: 'recyclingOrder', component: RecyclingOrderView }
    ]
  },
  {
    path: '/login',
    name: 'login',
    component: LoginView
  },
  {
    path: '/register',
    name: 'register',
    component: RegisterView
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
